package cn.shengchao.examstar.rpc.product.base;

import lombok.Data;

import java.io.Serializable;

/**
 * @program: examstarapi
 * @description: 课程属性数据传输对象
 * @author: Xiong weiqiang
 * @create: 2025-06-28 10:08
 */
@Data
public class ProductPropertyDto implements Serializable {
    private Long productId;
    private String productType;
    private String productName;
    private ProductSettingDto courseProductSettingDto;

    public static ProductPropertyDto buildLocalCourse(Long productId, String productName){
        ProductPropertyDto courseProductPropertyDto = new ProductPropertyDto();
        courseProductPropertyDto.setProductId(productId);
        courseProductPropertyDto.setProductType(ContentProductType.COURSE.name());
        courseProductPropertyDto.setProductName(productName);
        //本地课程，两年
        ProductSettingDto courseProductSettingDto = ProductSettingDto.builder()
                .productId(productId)
                .productType(ContentProductType.COURSE.name())
                .unitPayDay(731)
                .build();
        courseProductPropertyDto.setCourseProductSettingDto(courseProductSettingDto);
        return courseProductPropertyDto;
    }
    public static ProductPropertyDto buildCAP(Long productId, String productName){
        ProductPropertyDto courseProductPropertyDto = new ProductPropertyDto();
        courseProductPropertyDto.setProductId(productId);
        courseProductPropertyDto.setProductType("PRODUCT_THIRD_CAP");
        courseProductPropertyDto.setProductName(productName);
        //本地课程，两年
        ProductSettingDto courseProductSettingDto = ProductSettingDto.builder()
                .productId(productId)
                .productType("PRODUCT_THIRD_CAP")
                .unitPayDay(0)
                .build();
        courseProductPropertyDto.setCourseProductSettingDto(courseProductSettingDto);
        return courseProductPropertyDto;
    }
    public static ProductPropertyDto buildThirdYcbdc(Long productId, String productName){
        if (productId!=null&&productId.toString().startsWith("190334949289199560")){
            ProductPropertyDto courseProductPropertyDto = new ProductPropertyDto();
            courseProductPropertyDto.setProductId(productId);
            courseProductPropertyDto.setProductType("PRODUCT_THIRD_YCBDC");
            courseProductPropertyDto.setProductName(productName);
            int days=0;
            if (productId.toString().endsWith("1")){
                days=30;
            }else if (productId.toString().endsWith("2")){
                days=90;
            }else if (productId.toString().endsWith("3")){
                days=366;
            }
            //本地课程，两年
            ProductSettingDto courseProductSettingDto = ProductSettingDto.builder()
                    .productId(productId)
                    .productType("PRODUCT_THIRD_YCBDC")
                    .unitPayDay(days)
                    .build();
            courseProductPropertyDto.setCourseProductSettingDto(courseProductSettingDto);
            return courseProductPropertyDto;
        }
        return null;

    }
    public static ProductPropertyDto buildGklCourse(Long productId, String productName,Integer settingDays){
        ProductPropertyDto courseProductPropertyDto = new ProductPropertyDto();
        courseProductPropertyDto.setProductId(productId);
        courseProductPropertyDto.setProductType("COURSE_GK");
        courseProductPropertyDto.setProductName(productName);
        //本地课程，两年
        ProductSettingDto courseProductSettingDto = ProductSettingDto.builder()
                .productId(productId)
                .productType("COURSE_GK")
                .unitPayDay(settingDays)
                .build();
        courseProductPropertyDto.setCourseProductSettingDto(courseProductSettingDto);
        return courseProductPropertyDto;
    }
}